/*
 * @Description:
 * @version:
 * @Author: sunqian_sr
 * @Date: 2022-11-22 15:35:26
 * @LastEditors: Andy
 * @LastEditTime: 2023-01-17 10:23:34
 */
const context = import.meta.glob('../../modules/**/**/router.js', { eager: true })
const whiteList = ['login', 'errorPage']
let parentRoutes = []
let subRoutes = []
Object.keys(context).forEach((key) => {
  const files = key
  const [path, module, base, fileName] = files.replace(/(\..\/|\/module\/|\.js)/g, '').split('/')
  const tempObj = {}
  tempObj[module] = context[key].default
  if (whiteList.includes(module)) {
    parentRoutes = [...parentRoutes, ...tempObj[module]]
  } else {
    subRoutes = [...subRoutes, ...tempObj[module]]
  }
})
export { parentRoutes, subRoutes }
